package net.liteheaven.dtimer.timer

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import net.liteheaven.dtimer.XLog
import net.liteheaven.dtimer.timer.DTimerConst.Companion.ACTION_D_TIMER
import net.liteheaven.dtimer.timer.DTimerConst.Companion.EXTRA_TIMER_ID

/**
 * Created by LiangYu on 2018/7/30.
 */
class DTimerReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context?, intent: Intent?) {
        val action = intent!!.action
        if (ACTION_D_TIMER == action){
            val timerId = intent.getIntExtra(EXTRA_TIMER_ID, 0)
            XLog.i("onReceive timerId = $timerId")
            if (timerId > 0) {
                DTimerManager.dispatch(timerId)
            }
        }
    }
}